﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Whisper.Objects;
using Whisper.UI.Win.UserControls;

namespace Whisper.UI.Win
{
    static class Program
    {
        private static FormMain _formMain;
        private static ConversationServiceAdapter _adapter;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
           
            _formMain = new FormMain();
           
            LoadListConversations();
            LoadCreateConversations();

            Application.Run(_formMain);
        }

        private static void LoadCreateConversations()
        {
            const string createConversationsControlKey = "createConversations";
            var addConversationsControl = new AddConversationControl();
            var controller = new CreateConversationClientController(_adapter, addConversationsControl);

            _formMain.mainTabControl.TabPages.Add(createConversationsControlKey, "Create Conversations");
            _formMain.mainTabControl.TabPages[createConversationsControlKey].Controls.Add(addConversationsControl);
        }

        private static void LoadListConversations()
        {
            const string listConversationsControlKey = "ListConversations";
            var listConversationsControl = new UserControls.ListConversationsControl();

            _adapter = new ConversationServiceAdapter();
            var controller = new RetrieveConversationClientController(_adapter, listConversationsControl);
           
            _formMain.mainTabControl.TabPages.Add(listConversationsControlKey,"List Available Conversations");
            _formMain.mainTabControl.TabPages[listConversationsControlKey].Controls.Add(listConversationsControl);
        }
    }
}
